package com.iflytek.exam.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.iflytek.common.annotation.Log;
import com.iflytek.common.core.controller.BaseController;
import com.iflytek.common.core.domain.AjaxResult;
import com.iflytek.common.enums.BusinessType;
import com.iflytek.exam.domain.PaperInfo;
import com.iflytek.exam.service.IPaperInfoService;
import com.iflytek.common.utils.poi.ExcelUtil;
import com.iflytek.common.core.page.TableDataInfo;

/**
 * 记录试卷答案Controller
 * 
 * @author KK
 * @date 2024-07-09
 */
@RestController
@RequestMapping("/exam/info")
public class PaperInfoController extends BaseController
{
    @Autowired
    private IPaperInfoService paperInfoService;

    /**
     * 查询记录试卷答案列表
     */
    @PreAuthorize("@ss.hasPermi('exam:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(PaperInfo paperInfo)
    {
        startPage();
        List<PaperInfo> list = paperInfoService.selectPaperInfoList(paperInfo);
        return getDataTable(list);
    }

    /**
     * 导出记录试卷答案列表
     */
    @PreAuthorize("@ss.hasPermi('exam:info:export')")
    @Log(title = "记录试卷答案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PaperInfo paperInfo)
    {
        List<PaperInfo> list = paperInfoService.selectPaperInfoList(paperInfo);
        ExcelUtil<PaperInfo> util = new ExcelUtil<PaperInfo>(PaperInfo.class);
        util.exportExcel(response, list, "记录试卷答案数据");
    }

    /**
     * 获取记录试卷答案详细信息
     */
    @PreAuthorize("@ss.hasPermi('exam:info:query')")
    @GetMapping(value = "/{quId}")
    public AjaxResult getInfo(@PathVariable("quId") Long quId)
    {
        return success(paperInfoService.selectPaperInfoByQuId(quId));
    }

    /**
     * 新增记录试卷答案
     */
    @PreAuthorize("@ss.hasPermi('exam:info:add')")
    @Log(title = "记录试卷答案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PaperInfo paperInfo)
    {
        return toAjax(paperInfoService.insertPaperInfo(paperInfo));
    }

    /**
     * 修改记录试卷答案
     */
    @PreAuthorize("@ss.hasPermi('exam:info:edit')")
    @Log(title = "记录试卷答案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PaperInfo paperInfo)
    {
        return toAjax(paperInfoService.updatePaperInfo(paperInfo));
    }

    /**
     * 删除记录试卷答案
     */
    @PreAuthorize("@ss.hasPermi('exam:info:remove')")
    @Log(title = "记录试卷答案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{quIds}")
    public AjaxResult remove(@PathVariable Long[] quIds)
    {
        return toAjax(paperInfoService.deletePaperInfoByQuIds(quIds));
    }
}
